
    var selectedOptions_M = [];
    var rowNum_M = 1;

    // 更新选中的多选框值
    function updateSelection_M(option) {
    var index = selectedOptions_M.indexOf(option);
    if (index === -1) {
    selectedOptions_M.push(option);
} else {
    selectedOptions_M.splice(index, 1);
}
}

    // 添加到表格
    function addToTable_M() {
    var userInputText = document.getElementById('userInputText').value.trim();
    var resultTable_2 = document.getElementById('resultTable_2');
    var tableBody = document.getElementById('tableBody_M');

    if (userInputText !== '') {
    // 将用户输入的文本添加到表格中
    var newRow = tableBody.insertRow();
    var indexCell = newRow.insertCell();
    var contentCell = newRow.insertCell();

    indexCell.textContent = rowNum_M;
    rowNum_M++;

    contentCell.textContent = userInputText;
    // 清空用户输入文本框
    document.getElementById('userInputText').value = '';
}
    else if (selectedOptions_M.length > 0) {
    // 将多选框的值按点击顺序添加到表格中
    var newRow = tableBody.insertRow();
    var indexCell = newRow.insertCell();
    var contentCell = newRow.insertCell();

    indexCell.textContent = rowNum_M;
    rowNum_M++;

    contentCell.textContent = selectedOptions_M.join('');

    // 清空多选框选中记录
    var checkboxes = document.querySelectorAll('input[name^="fumai"]');
    for (var i = 0; i < checkboxes.length; i++) {
    checkboxes[i].checked = false;
}
    selectedOptions_M = [];
}
}

    // 清空表格和序号
    function clearTable_M() {
    var resultTable_2 = document.getElementById('resultTable_2');
    var tableBody = document.getElementById('tableBody_M');
    tableBody.innerHTML = ''; // 清空表格内容
    rowNum_M = 1; // 重置序号为1
}
